<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html >
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<title>系统首页</title>
</head>

<body>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>修改密码</h2>
            </div>
			<div class="subfiled-content">
	            <form class="saper-form" action="" method="post">
	            	<div class="kv-item clearfix">
	                    <label>用户名：</label>
	                    <div class="kv-item-content">
	                        <div class="user-name" style="line-height:30px;"  id="user-name">${emp.employeeLoginname}<input type="text" value="${emp.employeeLoginname}" id="employeeLoginname" style="display: none"></div>
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>原密码：</label>
	                    <div class="kv-item-content">
	                        <input type="password" placeholder="原密码" name="ypassword" id="ypassword">
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>新密码：</label>
	                    <div class="kv-item-content">
	                        <input type="password" placeholder="新密码" name="password1" id="password1">
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>确认密码：</label>
	                    <div class="kv-item-content">
	                        <input type="password" placeholder="确认密码" name="password2" id="password2"><span id="xs"></span>
	                    </div>
	                </div>
	                <div class="buttons">
	                    <a href="javascript:;" class="sapar-btn sapar-btn-recom">确定</a>
	                </div>
	            </form>
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>
    <font color="red"> </font>

<script type="text/javascript">
$(function(){
	$(".sapar-btn-recom").click(function(){
		var password1 = $("#password1").val();
		var password2 = $("#password2").val();
		if( password1!=password2){
			$("#xs").html("<font color='red'>两次密码不一致，请核对再重新输入</font>");
			return false;
		}
		var employeeLoginname =$("#employeeLoginname").val();
		var ypassword = $("#ypassword").val();
		$.ajax({
	          type: "POST",
	          url:"${ctx}/employee/mimaUpdate.do",
	          data:{
	        	  "username":employeeLoginname,"password":ypassword,"newpassword":password2
	          },
	          error: function(request) {
	         	 	layer.alert("网络故障，请稍后再试!");
	          },
	          success: function(data) {
	        	console.log(data);
	          	if(data.status=="true"){
	           		layer.alert("修改成功", function(){
	           			window.location.reload();;
           		    });
	           		
	          	}else{
	          		$("#xs").html("");
	          		layer.alert(data.msg+"请核对原密码");	          		
	          	}
	          }
		});
	});
});

</script>
</body>
</html>